import { request, post } from "@/utils/request";
import ApiResult from "@/api/base/ApiResult";
import {
  staffAdd,
  staffUpdate,
  staffStatus,
  staffDel,
  staffDetail,
  staffQuery,
  IQRCodeData,
  IBindWechatData, IUnbindWechatData,
} from "@/api/modules/orgStaff";
import {IQRCodeStatusData, IQRCodeStatusRes} from "@/api/modules/login";

/**
 * 获取员工列表
 * @returns {promise} Promise
 */
export async function pageList(data: staffQuery) {
  const rs: ApiResult<any> = await request(`merchant/admin/pageList`, data);
  return rs;
}
/**
 * 新增员工
 * @returns {promise} Promise
 */
export async function addNew(data: staffAdd) {
  const rs: ApiResult<any> = await request("merchant/admin/addNew", data);
  return rs;
}
/**
 * 更新员工
 * @returns {promise} Promise
 */
export async function update(data: staffUpdate) {
  const rs: ApiResult<any> = await request("merchant/admin/update", data);
  return rs;
}
/**
 * 更新员工状态
 * @returns {promise} Promise
 */
export async function upStatus(data: staffStatus) {
  const rs: ApiResult<any> = await request("merchant/admin/upStatus", data);
  return rs;
}
/**
 * 详情员工
 * @returns {promise} Promise
 */
export async function detail(data: staffDetail) {
  const rs: ApiResult<any> = await request("merchant/admin/detail", data);
  return rs;
}
/**
 * 删除员工
 * @returns {promise} Promise
 */
export async function del(data: staffDel) {
  const rs: ApiResult<any> = await request("merchant/admin/del", data);
  return rs;
}

/**
 * 获取绑定微信账号的二维码
 */
export async function getQrcode(data: IQRCodeData): Promise<ApiResult<any>> {
  return post('permission/login/wx/getBindQRCode ', data)
}

/**
 * 获取微信绑定二维码扫码状态
 */
export async function getBindQRCodeStatus(data: IQRCodeStatusData): Promise<ApiResult<IQRCodeStatusRes>> {
  return post('permission/login/wx/getBindQRCodeStatus', data)
}

/**
 * 绑定微信账号
 */
export async function bindWechat(data: IBindWechatData): Promise<ApiResult<any>> {
  return post("permission/login/wx/bind", data)
}

/**
 * 解绑微信账号
 */
export async function unbindWechat(data: IUnbindWechatData): Promise<ApiResult<any>> {
  return post("permission/login/wx/unBind", data)
}

// 不再提示微信绑定
export async function doNotNoticeBindWechat(data: {id: number, bindWxPromptStatus: number}): Promise<ApiResult<any>> {
  return request('merchant/admin/updateBindWxPromptStatus', data)
}
